package com.itheima.controller;

import com.itheima.common.Com.Order;
import com.itheima.common.pojo.PageInfo;
import com.itheima.common.pojo.Result;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 修改订单状态
     * @param status
     * @param id
     * @return
     */
    @PutMapping
    public Result updateOrder(@RequestBody Order order) {

        Boolean update = orderService.update(order);

        return Result.success("成功",update);

    }

    /**
     * 凡是参数后面带？号的要用@RequestParam注解
     * 分页查询
     * @param beginTime
     * @param endTime
     * @param number
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public Result page(@RequestParam(defaultValue = "") String beginTime
            ,@RequestParam(defaultValue = "") String endTime
            ,@RequestParam(defaultValue = "") String number
            ,@RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer pageSize){
        //一定要记得返回数据
        PageInfo<Order> page1 = orderService.page(beginTime, endTime, number, page, pageSize);
        return Result.success("成功",page1);
    }



}
